package org.ekingstar.qd.web.action;

import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.config.Action;
import org.apache.struts2.config.Result;
import org.apache.struts2.config.Results;
import org.apache.struts2.dispatcher.ServletActionRedirectResult;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.conversion.annotations.Conversion;
import com.ekingstar.framework.action.Menu;
import com.ekingstar.framework.app.ApplicationParameter;
import com.ekingstar.framework.domain.Function;
import com.ekingstar.framework.domain.User;
import com.ekingstar.framework.security.UserUtil;
import com.ekingstar.framework.service.IRoleService;
import com.ekingstar.framework.service.IUserService;
import com.ekingstar.framework.service.impl.UserRoleServiceImpl;
import com.ekingstar.framework.util.Page;
import com.ekingstar.framework.util.ServiceLocator;

import org.ekingstar.component.excel.ExportExcel;
import org.ekingstar.qd.domain.Catalog;
import org.ekingstar.qd.domain.QdDomain;
import org.ekingstar.qd.domain.QdCompareCond;
import org.ekingstar.qd.domain.QdHisCond;
import org.ekingstar.qd.domain.QdMark;
import org.ekingstar.qd.domain.QdSimplemeasu;
import org.ekingstar.qd.domain.QdWhereClause;
import org.ekingstar.qd.domain.DeployQdCompareCond;
import org.ekingstar.qd.domain.DeployQdSimplemeasu;
import org.ekingstar.qd.domain.DeployQdWhereClause;
import org.ekingstar.qd.service.CDoSearchService;
import org.ekingstar.qd.service.CMeasureService;
import org.ekingstar.qd.service.CCatalogService;
import org.ekingstar.qd.service.CConditionService;
import org.ekingstar.qd.service.CDomainService;
import org.ekingstar.qd.service.CDeployService;


/**
 * @descript 主题查询
 * @author 
 * @version 1.0
 */
@Action(name = "qdDomainSearch", namespace = "/querythemes")
@Results( {
		@Result(name = "commonSearch",         value = "/pages/querythemes/query/commonSearch.jsp"),
		@Result(name = "builderMultiList",         value = "/pages/querythemes/query/multiList.jsp"),	
		@Result(name = "builderTree",       value = "/pages/querythemes/query/multiTree.jsp"),		
		@Result(name = "hightSearch",      value = "/pages/querythemes/query/hightSearch.jsp"),
		@Result(name = "commonSearchResult",       value = "/pages/querythemes/query/commonSearchResult.jsp"),		
		@Result(name = "hisCondition",       value = "/pages/querythemes/query/hisCondition.jsp"),
		@Result(name = "faile",             value = "/pages/querythemes/query/error.jsp")})
public class DomainSearchAction extends ActionSupport{
	private static final long serialVersionUID = 2948401175556827608L;
	private CDeployService deployService;
	private CDomainService domainService;
	private CMeasureService measureService;
	private CConditionService conditionService;
	private CCatalogService catalogService;
	private CDoSearchService doSearchService ;
	
	private Page page;
	private int pageNo = 1;
	private int pageSize = ApplicationParameter.INSTANCE.getPageSize();
	
	private String strDomainId;
	private QdDomain qdDomain;
	private List<QdHisCond> hisConditionList;
	private int hisConditionListSize;
	private List<QdCompareCond> searchConditionList;
	private List<QdSimplemeasu> simplemeasuList;
	private int searchConditionListSize;
	private String title;
	private String strCompareCondId;
	private List dataList;
	private QdCompareCond qdCompareCond;
	private List<QdSimplemeasu> titleFieldList;
	private String strSql;
	private int countField;
	private String condstrcn;
	private String condstr;
	private String fieldstr;
	private String orderstr;
	private String ordertypestr;
	private String searchType;
	private String saveType;
	
	
	
//	private String strCatalogId;
//	private QdDomain searchQdDomain;
//		
//	private String strRoleId;
//	private List roleList;
//	private List<Catalog> catalogList; 
//	private List<QdSimplemeasu> simplemeasuList;
//	
//	private List<QdWhereClause> whereClauseList;
//	private List<QdSimplemeasu> deploySimplemeasuList;
//	private List<QdCompareCond> deployCompareCondList;
//	private List<QdWhereClause> deployWhereClauseList;

	public CDeployService getDeployService() {
		return deployService;
	}
	
	public void setDeployService(CDeployService deployService) {
		this.deployService = deployService;
	}
	
	public CDomainService getDomainService() {
		return domainService;
	}
	
	public void setDomainService(CDomainService domainService) {
		this.domainService = domainService;
	}
	
	public CMeasureService getMeasureService() {
		return measureService;
	}
	
	public void setMeasureService(CMeasureService measureService) {
		this.measureService = measureService;
	}
	
	public CConditionService getConditionService() {
		return conditionService;
	}
	
	public void setConditionService(CConditionService conditionService) {
		this.conditionService = conditionService;
	}
	
	public CCatalogService getCatalogService() {
		return catalogService;
	}
	
	public void setCatalogService(CCatalogService catalogService) {
		this.catalogService = catalogService;
	}	
	
	public CDoSearchService getDoSearchService() {
		return doSearchService;
	}

	public void setDoSearchService(CDoSearchService doSearchService) {
		this.doSearchService = doSearchService;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public String getStrDomainId() {
		return strDomainId;
	}

	public void setStrDomainId(String strDomainId) {
		this.strDomainId = strDomainId;
	}

	public QdDomain getQdDomain() {
		return qdDomain;
	}

	public void setQdDomain(QdDomain qdDomain) {
		this.qdDomain = qdDomain;
	}
	
	public List<QdHisCond> getHisConditionList() {
		return hisConditionList;
	}	
	
	public int getHisConditionListSize() {
		return hisConditionListSize;
	}

	public void setHisConditionListSize(int hisConditionListSize) {
		this.hisConditionListSize = hisConditionListSize;
	}

	public void setHisConditionList(List<QdHisCond> hisConditionList) {
		this.hisConditionList = hisConditionList;
	}

	public List<QdCompareCond> getSearchConditionList() {
		return searchConditionList;
	}

	public void setSearchConditionList(List<QdCompareCond> searchConditionList) {
		this.searchConditionList = searchConditionList;
	}	
		
	public List<QdSimplemeasu> getSimplemeasuList() {
		return simplemeasuList;
	}

	public void setSimplemeasuList(List<QdSimplemeasu> simplemeasuList) {
		this.simplemeasuList = simplemeasuList;
	}

	public int getSearchConditionListSize() {
		return searchConditionListSize;
	}

	public void setSearchConditionListSize(int searchConditionListSize) {
		this.searchConditionListSize = searchConditionListSize;
	}	

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}
	
	public String getStrCompareCondId() {
		return strCompareCondId;
	}

	public void setStrCompareCondId(String strCompareCondId) {
		this.strCompareCondId = strCompareCondId;
	}

	public List getDataList() {
		return dataList;
	}

	public void setDataList(List dataList) {
		this.dataList = dataList;
	}

	public QdCompareCond getQdCompareCond() {
		return qdCompareCond;
	}

	public void setQdCompareCond(QdCompareCond qdCompareCond) {
		this.qdCompareCond = qdCompareCond;
	}

	public List<QdSimplemeasu> getTitleFieldList() {
		return titleFieldList;
	}

	public void setTitleFieldList(List<QdSimplemeasu> titleFieldList) {
		this.titleFieldList = titleFieldList;
	}

	public String getStrSql() {
		return strSql;
	}

	public void setStrSql(String strSql) {
		this.strSql = strSql;
	}

	public int getCountField() {
		return countField;
	}

	public void setCountField(int countField) {
		this.countField = countField;
	}
	
	public String getCondstrcn() {
		return condstrcn;
	}

	public void setCondstrcn(String condstrcn) {
		this.condstrcn = condstrcn;
	}

	public String getCondstr() {
		return condstr;
	}

	public void setCondstr(String condstr) {
		this.condstr = condstr;
	}

	public String getFieldstr() {
		return fieldstr;
	}

	public void setFieldstr(String fieldstr) {
		this.fieldstr = fieldstr;
	}

	public String getOrderstr() {
		return orderstr;
	}

	public void setOrderstr(String orderstr) {
		this.orderstr = orderstr;
	}

	public String getOrdertypestr() {
		return ordertypestr;
	}

	public void setOrdertypestr(String ordertypestr) {
		this.ordertypestr = ordertypestr;
	}	

	public String getSearchType() {
		return searchType;
	}

	public void setSearchType(String searchType) {
		this.searchType = searchType;
	}
	
	public String getSaveType() {
		return saveType;
	}

	public void setSaveType(String saveType) {
		this.saveType = saveType;
	}

	//@descripte初始加载查询页面
	@SuppressWarnings("unused")
	public String load4Init(){		
		String retStr = "faile";
		try{
			//判断是否有权限
			if(doSearchService.checkRole(strDomainId)){
				qdDomain = domainService.getDomain(strDomainId);	
				title = doSearchService.getTitle(qdDomain)+"-"+"简单查询";
				hisConditionList = conditionService.getHisConditionByUserList(strDomainId);
				if(hisConditionList!=null && hisConditionList.size()>0){
					hisConditionListSize = hisConditionList.size();
				}else{
					hisConditionListSize = 0;
				}
				
				searchConditionList = doSearchService.getSearchList(strDomainId);
				if(searchConditionList!=null && searchConditionList.size()>0){
					searchConditionListSize = searchConditionList.size();
				}else{
					searchConditionListSize = 0;
				}
				retStr = "commonSearch";
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}
		
		return retStr;
	}
	
	
	public String load4OpenList(){
		String retStr = "faile";
		try{
			if(strCompareCondId!=null && !"".equals(strCompareCondId.toString().trim()) ){
				qdCompareCond = doSearchService.getQdCompareCond(strCompareCondId);
				dataList = doSearchService.getOpenList(strCompareCondId);
				retStr = "builderMultiList";
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}
		
		return retStr;
	}
	
	
	
	public String load4BuilderTree(){
		String jsonObject = "";
		try{
			//strCompareCondId ="1";
			HttpServletResponse response =  ServletActionContext.getResponse();	
			jsonObject =  doSearchService.getBuilderTree(strCompareCondId);
			response.setContentType("text/paint; charset=UTF-8");
			response.getWriter().print(jsonObject.toString());
		}catch(Exception e){
			e.printStackTrace();			
		}
		
		return null;
	}
	
	
	//@describe 简单查询
	public String doSearch(){
		String retStr = "faile";
		searchType = "1";
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			String[] searchConditionIdNames = request.getParameterValues("searchConditionIdNames");
			String[] searchConditionNames  = request.getParameterValues("searchConditionNames");
			String[] searchConditionValueNames = request.getParameterValues("searchConditionValueNames");
			//查询的主题
			qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());
			//页面标题
			title = doSearchService.getTitle(qdDomain)+"-"+"简单查询结果";
			
			//获取查询结果页面显示的字段标题
			titleFieldList = doSearchService.getFieldList(qdDomain.getId(),null,"1");
			
			//查询列表字段
			fieldstr = "";
			if(titleFieldList!=null && titleFieldList.size()>0){
				for(int i=0;i<titleFieldList.size();i++){
					QdSimplemeasu qdSimplemeasu = titleFieldList.get(i);
					if(qdSimplemeasu!=null && qdSimplemeasu.getId()!=null && !"".equals(qdSimplemeasu.getId().toString().trim())){
						if(fieldstr=="" || "".equals(fieldstr.toString().trim())){
							fieldstr = qdSimplemeasu.getId().toString().trim();
						}else{
							fieldstr = fieldstr+"######"+qdSimplemeasu.getId().toString().trim();
						}
					}
				}
			}
			
			//查询
			Object[] retString =doSearchService.doSearch(qdDomain.getId(),titleFieldList,searchConditionIdNames,searchConditionNames,searchConditionValueNames,pageNo, pageSize); 
			if(retString!=null && retString.length>=4){
				this.page = (Page)retString[0];
				this.strSql = (String)retString[1];
				this.countField = (new Integer(retString[2].toString().trim())).intValue();
				this.condstr = (String)retString[3];
				this.condstrcn = (String)retString[4];
				this.orderstr = "";
				this.ordertypestr="";
			}	
			
			retStr = "commonSearchResult";
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	//@describe 查询结果页面翻页等查询功能
	public String doReSearch(){
		String retStr = "faile";
		try{
			//查询的主题
			qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());
			//获取查询结果页面显示的字段标题
			titleFieldList = doSearchService.getFieldList(qdDomain.getId(),fieldstr,"2");
			//页面标题
			if(searchType!=null && !"".equals(searchType.toString().trim()) ){
				if(searchType=="1" || "1".equals(searchType.toString().trim())){
					title = doSearchService.getTitle(qdDomain)+"-"+"简单查询结果";
				}else{
					title = doSearchService.getTitle(qdDomain)+"-"+"高级查询结果";
				}
			}
					
			//查询
			Object[] retString =doSearchService.doHightSearch(qdDomain.getId(), titleFieldList, condstr, orderstr, ordertypestr, pageNo, pageSize);
			if(retString!=null && retString.length>=2){
				this.page = (Page)retString[0];
				this.strSql = (String)retString[1];
				this.countField = (new Integer(retString[2].toString().trim())).intValue();
			}
			
			retStr = "commonSearchResult";
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	//@descript 加载高级查询
	public String load4HightSearch(){
		String retStr = "faile";
		try{
			if(qdDomain!=null && qdDomain.getId()!=null && !"".equals(qdDomain.getId().toString().trim())){
				//判断是否有权限
				if(doSearchService.checkRole(qdDomain.getId().toString().trim())){
					qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());	
					title = doSearchService.getTitle(qdDomain)+"-"+"高级查询";
					
					
					searchConditionList = doSearchService.getSearchList(qdDomain.getId().toString().trim());
					if(searchConditionList!=null && searchConditionList.size()>0){
						searchConditionListSize = searchConditionList.size();
					}else{
						searchConditionListSize = 0;
					}
					
					titleFieldList = doSearchService.getFieldList(qdDomain.getId().toString().trim(),null,"1");
					
					
					retStr = "hightSearch";
				}
				
			}			
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	
	//@descript 高级查询
	public String doHightSearch(){
		String retStr = "faile";
		searchType = "2";
		try{
			if(qdDomain!=null && qdDomain.getId()!=null && !"".equals(qdDomain.getId().toString().trim())){
				//判断是否有权限
				if(doSearchService.checkRole(qdDomain.getId().toString().trim())){
					HttpServletRequest request = ServletActionContext.getRequest();
					//查询的主题
					qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());
					//页面标题
					title = doSearchService.getTitle(qdDomain)+"-"+"高级查询结果";
					//查询条件中文描述和条件值
					condstrcn = request.getParameter("hightSearchConditionValueCnNames");
					condstr = request.getParameter("hightSearchConditionValueNames");
					
					//查询列表字段
					fieldstr = request.getParameter("fieldIds");
					
					//处理排序字段
					String[] sortFieldNames = request.getParameterValues("sortFieldNames");
					String[] orderByNames = request.getParameterValues("orderByNames");
					if(sortFieldNames!=null && sortFieldNames.length>0 && orderByNames!=null && orderByNames.length>0 && sortFieldNames.length==orderByNames.length){
						String orderstrTemp = "";
						String ordertypestrTemp = "";
						for(int i =0;i<sortFieldNames.length;i++){
							if(orderstrTemp=="" || "".equals(orderstrTemp.toString())){
								if(sortFieldNames[i]==null || "".equals(sortFieldNames[i].toString().trim())){
									orderstrTemp = "null";
								}else{
									orderstrTemp = sortFieldNames[i].toString().trim();
								}								
								if(orderByNames[i]==null || "".equals(orderByNames[i].toString().trim())){
									ordertypestrTemp = "null";
								}else{
									ordertypestrTemp = orderByNames[i].toString().trim();
								}
							}else{
								if(sortFieldNames[i]==null || "".equals(sortFieldNames[i].toString().trim())){
									orderstrTemp = orderstrTemp+"######"+"null";
								}else{
									orderstrTemp = orderstrTemp+"######"+sortFieldNames[i].toString().trim();
								}
								
								if(orderByNames[i]==null || "".equals(orderByNames[i].toString().trim())){
									ordertypestrTemp = ordertypestrTemp+"######"+"null";
								}else{
									ordertypestrTemp = ordertypestrTemp+"######"+orderByNames[i].toString().trim();
								}
							}
						}
						orderstr = orderstrTemp;
						ordertypestr = ordertypestrTemp;
					}else{
						orderstr = "";
						ordertypestr = "";
					}
					
					//获取查询结果页面显示的字段标题
					titleFieldList = doSearchService.getFieldList(qdDomain.getId(),fieldstr,"2");
					
					//查询
					Object[] retString =doSearchService.doHightSearch(qdDomain.getId(), titleFieldList, condstr, orderstr, ordertypestr, pageNo, pageSize);
					if(retString!=null && retString.length>=2){
						this.page = (Page)retString[0];
						this.strSql = (String)retString[1];
						this.countField = (new Integer(retString[2].toString().trim())).intValue();
					}
					
					retStr = "commonSearchResult";
				}				
			}			
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	//加载保存查询条件页面
	public String load4SaveHisCondition(){
		String retStr = "faile";
		try{
			String userId = UserUtil.getCurrentUserId();
			if(userId!=null && !"".equals(userId.toString().trim())){
				//查询的主题
				qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());
				//查询历史条件
				this.hisConditionList = conditionService.getHisConditionByUserList(strDomainId);
				if(hisConditionList!=null && hisConditionList.size()>0){
					hisConditionListSize = hisConditionList.size();
				}else{
					hisConditionListSize = 0;
				}
				
				//页面标题
				title = doSearchService.getTitle(qdDomain)+"-"+"查询历史条件";
				retStr = "hisCondition";
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}
		
		return retStr;
	}
	
	 
	//保存查询条件
	public String saveHisCondition(){
		String retStr = "faile";
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			String strName = request.getParameter("cName"); 
			String strDescript = request.getParameter("cDescript"); 
			if(conditionService.addHisCondition(strDomainId, strName, strDescript, condstr, condstrcn, fieldstr, orderstr, ordertypestr, searchType)>0){
				//查询的主题
				qdDomain = domainService.getDomain(strDomainId.toString().trim());
				//查询历史条件
				this.hisConditionList = conditionService.getHisConditionByUserList(strDomainId);
				if(hisConditionList!=null && hisConditionList.size()>0){
					hisConditionListSize = hisConditionList.size();
				}else{
					hisConditionListSize = 0;
				}
				
				//页面标题
				title = doSearchService.getTitle(qdDomain)+"-"+"查询历史条件";
				this.saveType = "1";
				
				request.setAttribute("msg", "操作成功");
				retStr = "hisCondition";
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		
		return retStr;
	}
	
	
	//从普通查询页面删除查询条件
	public String deleteHisConditionFromInitPage(){
		String retStr = "faile";
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			String qdHisConditionId = request.getParameter("qdHisConditionId"); 
			if(qdHisConditionId!=null && !"".equals(qdHisConditionId.toString().trim())){
				if(conditionService.delHisCondition(new String[]{qdHisConditionId})>0){
					return this.load4Init();
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	
	//从条件保存页面删除查询条件
	public String deleteHisConditionFromSavePage(){
		String retStr = "faile";
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			String qdHisConditionId = request.getParameter("qdHisConditionId"); 
			if(qdHisConditionId!=null && !"".equals(qdHisConditionId.toString().trim())){
				if(conditionService.delHisCondition(new String[]{qdHisConditionId})>0){
					//查询的主题
					qdDomain = domainService.getDomain(strDomainId.toString().trim());
					//查询历史条件
					this.hisConditionList = conditionService.getHisConditionByUserList(strDomainId);
					if(hisConditionList!=null && hisConditionList.size()>0){
						hisConditionListSize = hisConditionList.size();
					}else{
						hisConditionListSize = 0;
					}					
					//页面标题
					title = doSearchService.getTitle(qdDomain)+"-"+"查询历史条件";
					retStr = "hisCondition";
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	//调用历史条件进行查询
	public String doSearchByHisCondition(){
		String retStr = "faile";
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			String qdHisConditionId = request.getParameter("qdHisConditionId"); 
			this.strDomainId = this.qdDomain.getId();
			if(qdHisConditionId!=null && !"".equals(qdHisConditionId.toString().trim())){
				QdHisCond qdHisCond = conditionService.getHisCondition(qdHisConditionId);
				if(qdHisCond!=null && qdHisCond.getId()!=null && !"".equals(qdHisCond.getId().toString().trim())){
					this.condstr = qdHisCond.getCondstr();
					this.condstrcn = qdHisCond.getCondstrcn();
					this.fieldstr = qdHisCond.getFieldstr();
					this.orderstr = qdHisCond.getOrderstr();
					this.ordertypestr = qdHisCond.getOrdertypestr();
					this.searchType = qdHisCond.getContype();
					return this.doReSearch();
				}
			}
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}
	
	
	//调用excel导出功能
	public String doExportForExcel(){
		String retStr = "faile";
		try{
			HttpServletResponse response = ServletActionContext.getResponse();
			//查询的主题
			qdDomain = domainService.getDomain(qdDomain.getId().toString().trim());
			//获取查询结果页面显示的字段标题
			titleFieldList = doSearchService.getFieldList(qdDomain.getId(),fieldstr,"2");
			String[] columnName = new String[titleFieldList.size()];			
			if(titleFieldList!=null && titleFieldList.size()>0){
				for(int i = 0;i<titleFieldList.size();i++){
					QdSimplemeasu qdSimplemeasu = (QdSimplemeasu)titleFieldList.get(i);
					if(qdSimplemeasu!=null && qdSimplemeasu.getId()!=null && !"".equals(qdSimplemeasu.getId().toString().trim())){						
						columnName[i]=qdSimplemeasu.getName();
					}
				}				
			}
			
			//查询
			dataList = doSearchService.doExportForExcel(strDomainId, titleFieldList, condstr, orderstr,ordertypestr);
						
			ExportExcel excel = new ExportExcel();		
			excel.exportExcel(response, columnName, dataList);
			retStr = null;
			
		}catch(Exception e){
			e.printStackTrace();
			retStr = "faile";
		}		
		return retStr;
	}	
}
